{template head}
<script type="text/javascript" src="{STATICDIR}third/plupload/plupload.full.min.js"></script>
<script type="text/javascript">
var ajaxparam = {
		'url' : '{SITE_URL}/ajax/index.php'
};
function deladmin(id,status,str)
{
	if(id)
	{
		
		layer.confirm('你确定执行'+str+'操作吗？', {
		  time: 0 //不自动关闭
		  ,btn: ['很确定', '点错了']
		  ,yes: function(index){
		    layer.close(index);
		    
		    
		    var url = ajaxparam.url + '?m=cpUserStatus';
			var data = {
					'id' : id,
					'status':status,
					'str':str,
			};
			var callback = function(data){
				if(data.sign == 1)
				{
					layer.alert(data.msg,function(){
						window.location = window.location;
					});
				}
				else
				{
					if(data.msg)
					{
						layer.msg(data.msg);
					}
					else
					{
						layer.msg('操作失败');
					}
				}
			};
			makeAjax('post',url,data,callback);
		    
		    
		    
		    
		    
		    
		    
		    
		  }
		});
		
		
		
		
	}else{
		alert('参数错误');
	}
}

	function save(data)
	{
		layer.load();
			
		data.m = 'addUser';
		
		var url = '{SITE_URL}ajax/index.php';
		
		var callback = function(data)
		{
			layer.closeAll('loading');
			if(data.sign == 1)
			{
				layer.closeAll();
				
				layer.alert(data.msg,function(){
					window.location = window.location;
				});
			}
			else
			{
				if(data.msg)
				{
					layer.msg(data.msg);
				}
				else
				{
					layer.msg('异常错误');
				}
			}
		};
		makeAjax('post',url,data,callback);
	}
	
	function add()
	{
		
		var html = [];
		
		html.push('<div style="padding: 5px 10px;">手机号码：<input id="phone" type="text" class="mr15 w200 text"></div>');
		
		layer.open({
		  type: 1
		  ,title:'添加用户'
		  ,offset: 'auto' //具体配置参考：offset参数项
		  ,content: html.join('')
		  ,btn: '确认'
		  ,btnAlign: 'c' //按钮居中
		  ,shade:  [0.8, '#393D49'] //不显示遮罩
		  ,yes: function(){
		    var data = {};
		    data.phone = $('#phone').val();
		    if(data.phone)
		    {
		    	save(data);
		    }
		    else
		    {
		    	layer.msg('请填写手机号码');
		    }
		  }
		});
	}
	
</script>
<body>
<div class="wrapper">
	<div class="crumbs"><a href="{SITE_URL}index.php?a={$action}">{$fTitle}</a> &gt; <span>{$sTitle}</span> </div>
	
	<div class="container_tit clearfix mb20 ft14">
	
	<form action="{SITE_URL}index.php?a={$action}" method="get">
		<input type="hidden" name="a" value="{$action}" />
        
        <div class="choose fl mr15" style="padding-top:10px">
            <select class="select w150" name="type">
            	<option value="-1">查询条件</option>
            	<!--{if is_array($typearr)}-->
            	<!--{loop $typearr $key $one}-->
            	<!--{if $key==$parm['type']}-->
            	<option value="{$key}" selected>{$one}</option>
            	<!--{else}-->
            	<option value="{$key}">{$one}</option>
            	<!--{/if}-->
            	<!--{/loop}-->
            	<!--{/if}-->
            </select>
            <input type="text" id="keyword" name="keyword" class="mr15 w200 text" value="{$parm['keyword']}">
        </div>
        
        <div class="btn_box fl" style="padding-top:10px">
        	<span>注册时间段</span>
        	<input type="text" class="w200 text" style="width:220px;" class="text" format='time' name='start' id="start" value="{$parm['start']}" placeholder="请输入日期">
			<span>至</span>
			<input type="text" class="mr15 w200 text" style="width:220px;" class="text" format='time' name='end' id="end" value="{$parm['end']}" placeholder="请输入日期">
        </div>
       
        <div class="choose fl mr15" style="padding-top:10px">
        	<span>是否投资</span>
            <select class="select w150" name="status">
            	<option value="">请选择</option>
            	<option {if $parm['status']=='1'}selected{/if} value="1">是</option>
            	<option {if $parm['status']=='2'}selected{/if} value="2">否</option>
            </select>
        </div>
        
        <div class="btn_box fl" style="padding-top: 10px">
        	<input type="submit" name="submit" class="btnblue mr15" value="搜索">
        </div>
        {if adminpermission('Y','100000','100002')}
        <div class="btn_box fl" style="padding-top: 10px;">
        	<a onclick="add();" href="javascript:;" class="btnyellow mr15">新建用户</a>
        </div>
        {/if}
        {if adminpermission('Y','100000','100003')}
        <div class="btn_box fl" style="padding-top: 10px;">
        	<a id="btn1" href="javascript:;" class="btnyellow mr15">导入</a>
        </div>
        {/if}
        {if adminpermission('Y','100000','100004')}
        <div class="btn_box fl" style="padding-top: 10px;">
        	<a href="javascript:;" class="btnyellow mr15">导出</a>
        </div>
        {/if}
    </form>
    </div>
	<!-- list -->
	<table class="table">
		<thead>
			<tr class="bg_h_1">
				<th width="">ID</th>
				<th width="">手机号</th>
				<th width="">姓名</th>
				<th width="">身份证号</th>
				<th width="">是否投资</th>
				<th width="">推荐人</th>
				<th width="">注册时间</th>
				<th width="">最后登录时间</th>
            	<th width="">操作</th>
			</tr>
		</thead>
		<tbody>
		<!--{loop $list $key $one}-->
			<tr>
				<td style="text-align: center;">{$one['id']}</td>
				<td style="text-align: center;">{$one['loginname']}</td>
				<td style="text-align: center;">{$one['name']}</td>
				<td style="text-align: center;">{$one['idcard']}</td>
				<td style="text-align: center;">
					{if $one[touzi] == 1}
						是
					{elseif $one[touzi] == 2}
						否
					{/if}
				</td>
				<td style="text-align: center;">{$one['source']}</td>
				<td style="text-align: center;">{php echo time_formart($one['regtime'],2)}</td>
				<td style="text-align: center;">{php echo time_formart($one['lasttime'],2)}</td>
				<td style="text-align: center;">
					{if adminpermission('Y','100000','100001')}
					<a class="btn_look" href="{SITE_URL}index.php?a={$action}&m=detail&id={$one[id]}"  title="查看详情">查看详情</a>
					{/if}
				</td>
			</tr>
		<!--{/loop}-->
		</tbody>
	</table>
</div>

<!--{php pagenav($pageurl,$page,$pagetotal);}-->
{template foot}

<script>
    var uploader = new plupload.Uploader({//创建实例的构造方法
        runtimes: 'html5,flash,silverlight,html4', //上传插件初始化选用那种方式的优先级顺序
        browse_button: 'btn1', // 上传按钮
        url: "{SITE_URL}ajax/index.php?m=daoru", //远程上传地址
        flash_swf_url: '{STATICDIR}plupload/Moxie.swf', //flash文件地址
        silverlight_xap_url: '{STATICDIR}plupload/Moxie.xap', //silverlight文件地址
        filters: {
            max_file_size: '20mb', //最大上传文件大小（格式100b, 10kb, 10mb, 1gb）
            mime_types: [//允许文件上传类型
                {title: "files", extensions: "xls,xlsx"}
            ]
        },
        multi_selection: false, //true:ctrl多文件上传, false 单文件上传
        init: {
            FilesAdded: function(up, files) { //文件上传前
                if ($("#ul_pics").children("li").length > 30) {
                    ts("您上传的图片太多了！");
                    uploader.destroy();
                } else {
                    var li = '';
                    plupload.each(files, function(file) { //遍历文件
                        li += "<li id='" + file['id'] + "'><div class='progress'><span class='bar'></span><span class='percent'>0%</span></div></li>";
                    });
                    $("#ul_pics").append(li);
                    uploader.start();
                }
            },
            UploadProgress: function(up, file) { //上传中，显示进度条
         var percent = file.percent;
                $("#" + file.id).find('.bar').css({"width": percent + "%"});
                $("#" + file.id).find(".percent").text(percent + "%");
            },
            FileUploaded: function(up, file, info) { //文件上传成功的时候触发
	                var data = eval("(" + info.response + ")");
	     			if(data.sign == 1)
					{
						layer.closeAll();
						
						layer.alert(data.msg,function(){
							window.location = window.location;
						});
					}
					else
					{
						if(data.msg)
						{
							layer.msg(data.msg);
						}
						else
						{
							layer.msg('异常错误');
						}
					}
	            },
            Error: function(up, err) { //上传出错的时候触发
                layer.msg(err.message);
            },
            UploadComplete:function()
            {
            	//layer.msg('上传成功,处理中');
            }
        }
    });
    uploader.init();
</script>